//侧滑导航栏
mui.init();
//解决a标签问题
mui('.select-nav-depart li').on('tap','a',function(){
	var url = $(this).data("url");
	window.location.href = this.url;
	document.location.href = this.href;
});


if (!mui.os.android) {
	var spans = document.querySelectorAll('.android-only');
	for (var i = 0, len = spans.length; i < len; i++) {
		spans[i].style.display = "none";
	}
}
 //主界面和侧滑菜单界面均支持区域滚动；
mui('#offCanvasSideScroll').scroll();
mui('#offCanvasContentScroll').scroll();
 //实现ios平台原生侧滑关闭页面；
if (mui.os.plus && mui.os.ios) {
	mui.plusReady(function() { //5+ iOS暂时无法屏蔽popGesture时传递touch事件，故该demo直接屏蔽popGesture功能
		plus.webview.currentWebview().setStyle({
			'popGesture': 'none'
		});
	});
}

//顶部底部触控
$(document).ready(function(){
	var i = 0;
	$("#offCanvasContentScroll").on('tap',function(){
		i++;
		setTimeout(function(){
			i=0;
		},300);
		//双击触发
		if(i>1){
			//点击区域不在报表中时
			if($(".mui-bar").is(':hidden')){
				$("#offCanvasContentScroll").css({"padding-top":"44px"});
				$("body").css({"padding-bottom":"84px !important"});
				
			}else{
				$("#offCanvasContentScroll").css({"padding-top":"0px"});
				$("body").css({"padding-bottom":"0px !important"});
			}
			$(".mui-bar").slideToggle(200);
			i = 0;
		}
	});
});

//Echarts图表自适应
$(window).resize(function(){
	location.reload();
});

//进入页面后刷新且仅刷新一次页面
$(document).ready(function(){
	if(location.href.indexOf("#reloaded")==-1){
		location.href=location.href+"#reloaded";
		location.reload();
	}
});

//如出错则需要放到html中（以下所有的js）
function requerst() {
	$.ajax({
		url : "ViewAllDetail.action",
		//async : true,
		//contentType: "application/x-www-form-urlencoded; charset=utf-8",
		type : 'post',
		dataType : 'json',
		timeout: 20000, //20秒超时
		data : {
		},
		error : function(textStatus) {
			console.log("Error:" + textStatus);
			/* 如果有错误返回到主界面 
			window.location.href="ViewAllDashBoard.action";*/
		},
		success : function(jsonData) {
			console.log(jsonData.xmltext);
			document.getElementById("dashboardlist").innerHTML = jsonData.xmltext;
			mui('.menuList_zhuye li').on('tap','a',function(){
				var url = $(this).data("url");
				window.location.href = this.url;
				document.location.href = this.href;
			});
		}
	});
}

//$('#slideRightCon').touchListener(380);
init();
function init(){
//   var wh = window.innerHeight
//   $("body").height(wh)
  var dataY = "2018"
  var dataM = "11"
   startNum = Number(window.location.hash.replace("#",""))
  ajaxDate(dataY,dataM,0,"ViewCustStruDashBoard1.action")
}


$("#datechange").on("change",function(){
  var thda = this.value

  dataY=thda.slice(0,4)
  dataM=thda.slice(4,6)
	$("#datetext").text(dataY+"-"+dataM)
  startNum = Number(window.location.hash.replace("#",""))
  ajaxDate(dataY,dataM,startNum,"ViewCustStruDashBoard1.action")
})


window.onresize=function(){
   window.location.reload();
}

$(".kkook").on("touchmove",function(e){
   e.stopPropagation();
})

mui('.menuList_zhuye li').on('tap','a',function(){
	document.location.href=this.href;
});
//如出错则需要放到html中（以上所有的js）